﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
@using CNKI.TPI.Web.Base;
<script>
    function publishSet(DbID) {
        var urlstr = "@Html.Raw(Url.Action("Config", "Admin_SingleDBPublish"))";
        var dataobj = { "DbID": DbID };
        ajaxLoad("initload", urlstr, dataobj);
    }
    function publishCancel(DbID) {
        confirmDialog('确定要取消发布吗?', function () {
            $.ajax({
                type: "POST",
                url: "@Html.Raw(Url.Action("Cancel", "Admin_SingleDBPublish"))",
                data: { "DbID": DbID },
                success: function (msg) {
                    if (msg == "True") {
                        messageAlert("操作成功！");
                        searchPageNew($('#pageIndexNow').val());//刷新页面
                    }
                    else {
                        messageAlert("操作失败！");
                    }

                },
                error: function (e)
                { }
            })
        })
    }
    function closeDbSort() {
        $(".talkDivBg").hide();
        $(".sortDB").hide();
    }
    function showDbSort() {
        $(".talkDivBg").show();
        $(".sortDB").show();
    }
    function saveDbSort() {
        ;
        var jsondata = [];
        $('.wrapR-c-box-b-right ul input').each(function (index) {
            var dataobj = {
                "SysID": $(this).val(),
                "SortSn": index,
            }
            jsondata.push(dataobj);

        })
        var dataold = { "list": jsondata };
        $.ajax({
            type: "POST",
            url: "@Html.Raw(Url.Action("UpdateDBSort", "Admin_SingleDBPublish"))",
            contentType: "application/json",
            data: JSON.stringify(dataold),
            success: function (msg) {
                if (msg == "True") {
                    closeDbSort();
                    searchPageNew($('#pageIndexNow').val());//刷新页面
                }
                else {
                    messageAlert("操作失败！");
                }
            },
            error: function (e)
            { }
        })

    }
</script>
<div class="wrapR-c">
    <table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey">
        <thead>
            <tr class="thead">
                <th class="tdnum">序号</th>
                <th class=''>数据库名称</th>
                <th class='tl'>数据库类型</th>
                <th>创建时间</th>
                <th>是否可见</th>
                <th>是否发布</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @{if (ViewBag.DbList != null)
              {

                  int sortno = ViewBag.PageSize * (ViewBag.PageNow - 1) + 1;
                  foreach (SYS_CMS_DATABASE item in ViewBag.DbList)
                  {

                      string str = "even";
                      if (sortno % 2 == 0)
                      {
                          str = "odd";
                      }
                <tr class='@str'>
                    <td>@sortno</td>
                    <td>@Html.Raw(ColumnAliasHelper.SubContent(item.DatabaseName, item.DatabaseName.Length))</td>
                    <td>@item.DatabaseTypeName</td>
                    <td class="tc">@if (item.CreateDate != null)
                                   {@item.CreateDate.ToString("yyyy-MM-dd")}</td>
                    <td class='tc'>
                        @if (item.VisibleFlag == 0)
                        {<i class="iconfont icon-close2 red"></i>}
                        else
                        {<i class="iconfont  icon-correct3 success"></i>}
                    </td>
                    <td class='tc'>
                        @{ 
                        string modifystr = "发布设置";
                        string canclestr = "";
                        if (item.DatabasePubFlag == 0)
                        {
                            <i class="iconfont icon-close2 red"></i>
                        }
                        else
                        {
                            modifystr = "修改设置";
                            <i class="iconfont  icon-correct3 success"></i>
                            canclestr = "&nbsp;&nbsp;&nbsp;<a onclick=\"publishCancel('" + item.SysID + "')\" href=\"javascript:void(0)\">取消发布</a>";
                        }
                        }
                    </td>
                    <td class="tc">
                        <a onclick="publishSet('@item.SysID')" href="javascript:void(0)">@modifystr</a>
                        @Html.Raw(canclestr)
                    </td>
                </tr>
                        sortno = sortno + 1;
                  }
              }

            }
        </tbody>
    </table>

    @*//分页*@
    <div class="pagenav pagenav-02">
        @*上一页*@
        @if (ViewBag.TotalPage > 0)
        {
            if (ViewBag.PageNow != 1)
            {
                int thispage = ViewBag.PageNow - 1;
            <a href="javascript:void(0);" class="page-prev" onclick="searchPageNew('@thispage')" >上一页</a>
            }
            else
            {
            <a href="javascript:return false;"  onclick="return false" class="page-prev disable">上一页</a>
            }
@*循环初始化页码*@
            foreach (string numpage in ViewBag.PageList)
            {
                if (numpage != "0")
                {
                    int m = int.Parse(numpage);
                    if (m == ViewBag.PageNow)
                    {
            <a href="javascript:void(0);" class="active" onclick="searchPageNew('@numpage')">@numpage</a>
                    
                    }
                    else
                    {
            <a href="javascript:void(0);" onclick="searchPageNew('@numpage')">@numpage</a>
                    }

                }
                else
                {
            <i class="iconfont icon-dian2"></i>
                }

            }
@*下一页*@
            if (ViewBag.TotalPage > 0 && ViewBag.PageNow != ViewBag.TotalPage)
            {
                int nextpage = ViewBag.PageNow + 1;
            <a href="javascript:void(0);" class="page-next" onclick="searchPageNew('@nextpage')" >下一页</a>
            }
            else
            {
            <a href="javascript:return false;"  onclick="return false" class="page-prev disable">下一页</a>
            }
        }
        @if (ViewBag.DbList == null || ViewBag.DbList.Count == 0)
        {
            <label>暂无数据！</label>
        
        }
        else
        {
          
            <label>共 </label>
            <label>@ViewBag.Count </label>
            <label>条数据 </label>
        }
    </div>
</div>



<!--透明背景-->
<div class="talkDivBg" style="display: none; z-index: 999">
    <div class="talkDiv talkDivTr talkW-550 form-h sortDB" style='margin-top: -278px; display: none'>
        <div class="talkDiv-title">
            <span>数据库排序</span>
            <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closeDbSort()"><i class="iconfont icon-error3"></i></a>
        </div>
        <div class="talkDiv-body talkDiv-body1">

            <div class="f-gp" style="padding-left: 70px">

                <div class='wrapR-c-box wrapR-c-r wrapR-c-r-l' style="overflow-y: visible; height: 430px">
                    <div class="wrapR-c-box-t">已发布数据库列表</div>
                    <div class="wrapR-c-box-b-right" style="overflow-y: scroll; height: 380px">
                        <ul class="ulfield">
                            @if (ViewBag.DBListALL != null)
                        {
                            foreach (SYS_CMS_DATABASE item in ViewBag.DBListALL)
                            {
                                if (item.DatabasePubFlag == 1 && item.VisibleFlag == 1)
                                {
                                        <li class="f-ct" style="margin-left: 2em;">
                                            <label class="f-label block right">
                                                <input type="checkbox" class="f-checkboxR" value='@item.SysID' />@item.DatabaseName
                                            </label>

                                        </li>
                                }
                            }
                        }
                        </ul>
                    </div>
                </div>

                <div class="wrapR-c-r-r form-h posa" style="top: 80px; left: 400px;">
                    <div>

                        <a title="移至最顶部" onclick=" movefirst(this)" class="iconfont-s iconfont-upest-s"></a>
                        <br />
                        <a title="上移" onclick="moveablove(this)" class="iconfont-s iconfont-up-s"></a>
                        <br />
                        <a title="下移" onclick="movedown(this)" class="iconfont-s iconfont-down-s"></a>
                        <br />
                        <a title="移至最底部" onclick="movelast(this)" class="iconfont-s iconfont-downest-s"></a>

                    </div>


                </div>
            </div>
            <div class="f-gp">
                <div class="f-lb">
                    <label class="f-label"></label>
                </div>
                <div class="f-ct" style="margin-left: 150px">
                    <a href="javascript:void(0);" class="btn btn-m btn-prim-f btn-submit" onclick="saveDbSort()">保存</a>
                </div>
            </div>

        </div>


    </div>
</div>